import request from '@/utils/request'

// 成员列表
export function getMemeberAll(data) {
  return request.service({
    url: '/memberuser/queryPage',
    method: 'post',
    data
  })
}

// 查询传播成员
export function getSpreadUser(data) {
  return request.service({
    url: '/memberuser/getSpreadUserPage',
    method: 'post',
    data
  })
}

// 查询成员
export function getMemeber(data) {
  return request.service({
    url: '/memberuser/query',
    method: 'post',
    data
  })
}

// 添加成员
export function addMember(data) {
  return request.service({
    url: '/memberuser/insert',
    method: 'post',
    data
  })
}

// 删除单个成员
export function deleteMember(params) {
  return request.service({
    url: '/memberuser/delete',
    method: 'delete',
    params
  })
}

// 删除多个成员
export function deleteAllMember(params) {
  let idArr = '?'
  params.id.forEach((item) => {
    idArr += 'id=' + item + "&"
  })
  idArr = idArr.substr(0,idArr.length-1)
  return request.service({
    url: '/memberuser/deleteBatch'+idArr,
    method: 'delete'
  })
}

// 搜索成员
export function searchMember(data) {
  return request.service({
    url: '/memberuser/searchPage',
    method: 'post',
    data
  })
}

// 查询单个成员
export function getMember(id) {
  return request.service({
    url: `/memberuser/get/${id}`,
    method: 'get'
  })
}

// 修改成员信息
export function updataMember(data) {
  return request.service({
    url: '/memberuser/update',
    method: 'put',
    data
  })
}

// 删除部门
export function deleteDepartment(params) {
  return request.service({
    url: '/department/delete',
    method: 'delete',
    params
  })
}

// 添加部门
export function addDepartment(data) {
  return request.service({
    url: '/department/insert',
    method: 'post',
    data
  })
}

// 获取部门
export function getDepartment(data = {}) {
  return request.service({
    url: '/department/query',
    method: 'post',
    data
  })
}

// 添加职位
export function addPosition(data) {
  return request.service({
    url: '/position/insert',
    method: 'post',
    data
  })
}

// 获取职位
export function getPosition(data = {}) {
  return request.service({
    url: '/position/query',
    method: 'post',
    data
  })
}

// 删除职位
export function deletePosition(params) {
  return request.service({
    url: '/position/delete',
    method: 'delete',
    params
  })
}

// 批量更新成员角色
export function updataMemberRole(data) {
  return request.service({
    url: '/memberuser/updateRoleBatch',
    method: 'put',
    data
  })
}

// 人员全部通过审核
export function updataAllAudit() {
  return request.service({
    url: '/memberuser/agreeAll',
    method: 'put'
  })
}

// 单个人员审核

export function updataAudit(data) {
  return request.service({
    url: '/memberuser/audit',
    method: 'put',
    data
  })
}